package com.fyl.pattern.facade;

public class SmartAppliancesFacade {
    //聚合电灯 电视机 空调对象
    private Light light;
    private TV tv;
    private AirCondition airCondition;

    public SmartAppliancesFacade() {
        light = new Light();
        tv = new TV();
        airCondition = new AirCondition();
    }
    //模拟通过声音控制
    public void say(String message) {
        if(message.contains("打开")){
            on();
        }else if(message.contains("关闭")){
            off();
        }else {
            System.out.println("我还听不懂你说的");
        }
    }
    //一键打开
    private void on() {
        light.on();
        tv.on();
        airCondition.on();
    }
    //一键关闭
    private void off() {
        light.off();
        tv.off();
        airCondition.off();
    }
}
